<!DOCTYPE html>
<html lang="">

<head>
	<meta name="generator" content="Hugo 0.73.0" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="author" content="Ap Chen ">
<meta name="description" content="安全性保护 (security) 防止非法使用数据库 要求用户通过规定的访问途径 要求按照规定的访问规则 Term 安全数据库（可信数据库） 适应网络环境下安全要求级别的数据库 可" />
<meta name="keywords" content="blog" />
<meta name="robots" content="noodp" />

<link rel="canonical" href="https://fziks.gitee.io/notes/database/5-%E5%AE%89%E5%85%A8%E6%80%A7%E4%B8%8E%E5%AE%8C%E6%95%B4%E6%80%A7/" />

<meta itemprop="name" content="5-安全性与完整性">
<meta itemprop="description" content="安全性保护 (security) 防止非法使用数据库 要求用户通过规定的访问途径 要求按照规定的访问规则 Term 安全数据库（可信数据库） 适应网络环境下安全要求级别的数据库 可">
<meta itemprop="datePublished" content="2019-05-26T00:00:00&#43;00:00" />
<meta itemprop="dateModified" content="2019-05-26T00:00:00&#43;00:00" />
<meta itemprop="wordCount" content="1155">



<meta itemprop="keywords" content="" />
<meta property="og:title" content="5-安全性与完整性" />
<meta property="og:description" content="安全性保护 (security) 防止非法使用数据库 要求用户通过规定的访问途径 要求按照规定的访问规则 Term 安全数据库（可信数据库） 适应网络环境下安全要求级别的数据库 可" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://fziks.gitee.io/notes/database/5-%E5%AE%89%E5%85%A8%E6%80%A7%E4%B8%8E%E5%AE%8C%E6%95%B4%E6%80%A7/" />
<meta property="article:published_time" content="2019-05-26T00:00:00+00:00" />
<meta property="article:modified_time" content="2019-05-26T00:00:00+00:00" />

<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="5-安全性与完整性"/>
<meta name="twitter:description" content="安全性保护 (security) 防止非法使用数据库 要求用户通过规定的访问途径 要求按照规定的访问规则 Term 安全数据库（可信数据库） 适应网络环境下安全要求级别的数据库 可"/>


<link rel="apple-touch-icon" sizes="60x60" href="https://fziks.gitee.io/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://fziks.gitee.io/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="https://fziks.gitee.io/icons/favicon-16x16.png">
<link rel="manifest" href="https://fziks.gitee.io/icons/site.webmanifest">
<link rel="mask-icon" href="https://fziks.gitee.io/icons/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="https://fziks.gitee.io/icons/favicon.ico">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-config" content="/icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">

<title>5-安全性与完整性</title>


<link rel="stylesheet" href="//at.alicdn.com/t/font_1559566_wk214kwa2dn.css">


    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">



    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css" integrity="sha256-WAgYcAck1C1/zEl5sBl5cfyhxtLgKGdpI3oKyJffVRI=" crossorigin="anonymous" />
    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.css" integrity="sha256-a2tobsqlbgLsWs7ZVUGgP5IvWZsx8bTNQpzsqCSm5mk=" crossorigin="anonymous" />
    
   <link href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/materia/bootstrap.min.css" rel="stylesheet" integrity="sha384-1tymk6x9Y5K+OF0tlmG2fDRcn67QGzBkiM3IgtJ3VrtGrIi5ryhHjKjeeS60f1FA" crossorigin="anonymous">
    
    
    <link rel="stylesheet" href="https://fziks.gitee.io/sass/main_cdn.min.270b43bb8631af4497ed45b90db42c517e86c9511418de9152f134d02ed32b87.min.2192baea245cf318085511589e62bfbdb3fbe4fb0eef718f1be9af91c10542ce.css" integity="sha256-IZK66iRc8xgIVRFYnmK/vbP75PsO73GPG&#43;mvkcEFQs4=">

</head>

<body style="overflow-x: unset;">
	<div class="container-fluid">
		<div class="row d-print-block">
			<div class="col-12 col-md-3 col-lg-2 bd-sidebar d-print-none">
				<div class="d-flex mt-3 border-bottom">
        <span class="navbar-brand w-100" style="display: grid;">
            <small>
                <a href="https://fziks.gitee.io/" class="text-black-50">
                    <i class="iconfont icon-back-arrow-"></i>
                </a>
                Ap Chen's
            </small>
            <a class="text-dark" href="https://fziks.gitee.io/notes/">
                Notes
            </a>
        </span>
        <button class="btn btn-link text-dark d-md-none p-0 ml-3" type="button" data-toggle="collapse"
            data-target="#bd-docs-nav" aria-controls="bd-docs-nav" aria-expanded="true"
            aria-label="Toggle docs navigation">
            <i class="fad fa-bars"></i>
        </button>
    </div>
				<nav id="bd-docs-nav" class="collapse bd-links">
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/computer-network/">
            
            
                <span class="icontext">S</span>
            
            
            计算机网络
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/operating-system/">
            
            
                <span class="icontext">S</span>
            
            
            操作系统
        </a>
    </div>
    
    
    
    <div class="bd-toc-item active bg-light">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/database/">
            <i class="iconfont icon-back-arrow-reverse"></i>
            数据库
        </a>
        <ul class="nav bd-sidenav">
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/1-%E6%A6%82%E8%BF%B0/">1-概述</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/2-%E6%95%B0%E6%8D%AE%E6%A8%A1%E5%9E%8B/">2-数据模型</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/3-%E5%85%B3%E7%B3%BB%E6%95%B0%E6%8D%AE%E5%BA%93%E7%B3%BB%E7%BB%9F/">3-关系数据库系统</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/8-%E8%A7%84%E8%8C%83%E5%8C%96%E7%90%86%E8%AE%BA/">8-规范化理论</a>
            </li>
            
            
            
            <li class="active">
                <a href="https://fziks.gitee.io/notes/database/5-%E5%AE%89%E5%85%A8%E6%80%A7%E4%B8%8E%E5%AE%8C%E6%95%B4%E6%80%A7/">
                    <i class="fad fa-chevron-right mr-1"></i>
                    5-安全性与完整性
                </a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/6-%E4%BA%8B%E5%8A%A1%E5%A4%84%E7%90%86/">6-事务处理</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/7-%E6%95%B0%E6%8D%AE%E5%BA%93%E7%9A%84%E7%89%A9%E7%90%86%E7%BB%84%E7%BB%87/">7-数据库的物理组织</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/8-%E6%95%B0%E6%8D%AE%E4%BA%A4%E6%8D%A2/">8-数据交换</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/database/9-%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AE%BE%E8%AE%A1/">9-数据库设计</a>
            </li>
            
            
        </ul>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/cs50-introduction-to-computer-science/">
            
            
                <span class="icontext">S</span>
            
            
            CS50 MIT
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/advanced-programming/">
            
            
                <span class="icontext">A</span>
            
            
            高级程序设计
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/deep-learning/">
            
            
                <span class="icontext">O</span>
            
            
            深度学习基础
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/%E6%96%87%E7%8C%AE%E7%AE%A1%E7%90%86%E4%B8%8E%E4%BF%A1%E6%81%AF%E5%88%86%E6%9E%90/">
            
            
                <span class="icontext">O</span>
            
            
            文献管理与信息分析
        </a>
    </div>
    
    
</nav>
			</div>
			<div class="col-12 col-md-9 col-lg-10 d-print-block">
				<div class="row d-print-block">
					<main class="col-12 col-md-10 col-lg-9 py-md-3 pl-md-5 bd-content d-print-block" role="main">
						<div id="title" class="my-4 border-bottom">
							<span>数据库</span>
							<h2>5-安全性与完整性</h2>
							<footer>
								<span>
									<i class="iconfont icon-NewFile mr-2"></i>
									2019-05-26 08:00 CST
								</span> <br />
								<span>
									<i class="iconfont icon-modify mr-2"></i>
									2019-05-26 08:00 CST
								</span> <br />
								<span>
									<i class="iconfont icon-copyright mr-2"></i>
									CC BY-NC 4.0
								</span>
							</footer>
						</div>
						<div id="content" class="hl-h2">
							
							
							
							
							
							
							
							
							
							
							
							
							<h2 id="安全性保护-security">安全性保护 (security)<a href="#安全性保护-security" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ul>
<li>防止非法使用数据库
<ul>
<li>要求用户通过规定的访问途径</li>
<li>要求按照规定的访问规则</li>
</ul>
</li>
</ul>
<table>
<thead>
<tr>
<th>Term</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>安全数据库（可信数据库）</td>
<td>适应网络环境下安全要求级别的数据库</td>
</tr>
<tr>
<td>可信计算基（TCB）</td>
<td>为实现数据库安全所采用的所有实施策略与机制的集合</td>
</tr>
<tr>
<td>主体</td>
<td>数据的访问者</td>
</tr>
<tr>
<td>客体</td>
<td>数据库中的数据</td>
</tr>
<tr>
<td>身份标识与鉴别</td>
<td>每个主体标识自己的标识符和访问口令</td>
</tr>
<tr>
<td>自主访问控制（DAC）</td>
<td>基于存取矩阵(HRU)的安全控制模型</td>
</tr>
<tr>
<td>存取权限</td>
<td></td>
</tr>
<tr>
<td>强制访问控制（MAC）</td>
<td>通过无法回避的存取限制来防止各种攻击</td>
</tr>
<tr>
<td>数据完整性</td>
<td>防止非法插入，删除，修改等影响数据完整性的操作</td>
</tr>
<tr>
<td>隐蔽通道</td>
<td>非正规的，不受 TCB 控制的访问通道</td>
</tr>
<tr>
<td>审计</td>
<td>跟踪用户对数据的访问操作</td>
</tr>
<tr>
<td>访问监控器</td>
<td>独立的机构，TCB 在网络中的实现</td>
</tr>
</tbody>
</table>
<ul>
<li>安全标准
<ul>
<li>1985 TCSEC</li>
<li>国际标准(ISO 15408) CC V2.1</li>
<li>国标：GB 17859-1999 计算机系统安全保护等级划分
<ul>
<li>第一级：用户自主保护级 (C1)
<ul>
<li>自主访问控制 + 身份鉴别 + 数据完整性</li>
</ul>
</li>
<li>第二级：系统审计保护级 (C2)
<ul>
<li>+ 客体重用 + 审计</li>
</ul>
</li>
<li>第三级：安全标记保护级 (B1)
<ul>
<li>+ 强制访问控制 + 标记</li>
</ul>
</li>
<li>第四级：结构化保护级 (B2)
<ul>
<li>+ 隐蔽信道分析 + 可信路径</li>
</ul>
</li>
<li>第五级：访问验证保护级 (B3)
<ul>
<li>+ 可信恢复</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>SQL'92 C1
<ul>
<li>自主访问控制：（用户，操作对象，操作权限）
<ul>
<li>操作权限：SELECT, INSERT, DELETE, UPDATE, REFERENCE, EXECUTE, USAGE</li>
<li>操作对象：表，属性，域，函数</li>
<li>授权语句 <code>GRANT &lt;操作权限列表&gt; ON &lt;操作对象&gt; TO &lt;用户名列表&gt; [OPTION]</code></li>
<li>回收语句 <code>REVOKE &lt;操作权限列表&gt; ON &lt;操作对象&gt; FROM &lt;用户名列表&gt; [RESTRICT|CASCADE]</code></li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="完整性保护-integrity">完整性保护 (integrity)<a href="#完整性保护-integrity" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ul>
<li>数据的正确性和一致性
<ul>
<li>正确性：数据的有效性，有意义</li>
<li>一致性：在多用户并发访问数据库的情况下，保证对数据的更新不会出现与实际不一致的情况</li>
</ul>
</li>
<li>完整性规则
<ul>
<li>实体完整性规则：在一个基表的主关键字中，属性取值不能为空</li>
<li>参照完整性
<ul>
<li>引用：$R$ 中有属性集与另一个关系的主关键字对应，则 $R$ 引用 $S$ 中的元组</li>
<li>$R$ 中每个元组在外关键字上不能引用不存在的实体</li>
</ul>
</li>
<li>用户自定义的完整性</li>
</ul>
</li>
<li>完整性约束规则
<ul>
<li>设置 <code>CONSTRAINT &lt;约束名&gt; &lt;完整性约束子句&gt;</code></li>
<li>检查</li>
<li>处理</li>
</ul>
</li>
<li>外键约束
<ul>
<li>Cascade: 同步做连带删除/更新</li>
<li>Restrict: 确保只有不存在相关视图和 完整性约束的表才能删除（拒绝对被引用表的删除/更新操作）</li>
<li>Set Null: 自动设为空</li>
<li>NOT ACTION: 不允许对ＲＥＦＥＲＥＮＣＥ进行修改</li>
</ul>
</li>
<li>属性级约束（域约束）</li>
</ul>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-SQL" data-lang="SQL"><span style="color:#a40000">{</span> <span style="color:#204a87;font-weight:bold">NOT</span> <span style="color:#204a87;font-weight:bold">NULL</span> 
<span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">DEFAULT</span> <span style="color:#a40000">{</span><span style="color:#204a87;font-weight:bold">default</span><span style="color:#a40000">\</span><span style="color:#000">_constant</span><span style="color:#ce5c00;font-weight:bold">|</span><span style="color:#204a87;font-weight:bold">NULL</span><span style="color:#a40000">}</span>
<span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">CONSTRAINT</span> <span style="color:#204a87;font-weight:bold">constraint</span><span style="color:#a40000">\</span><span style="color:#000">_name</span> <span style="color:#000;font-weight:bold">]</span>
      <span style="color:#204a87;font-weight:bold">UNIQUE</span>
    <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">PRIMARY</span> <span style="color:#204a87;font-weight:bold">KEY</span>
    <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">CHECK</span> <span style="color:#000;font-weight:bold">(</span> <span style="color:#204a87;font-weight:bold">search</span><span style="color:#a40000">\</span><span style="color:#000">_condition</span> <span style="color:#000;font-weight:bold">)</span>
    <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">REFERENCES</span> <span style="color:#204a87;font-weight:bold">table</span><span style="color:#a40000">\</span><span style="color:#000">_name</span> <span style="color:#000;font-weight:bold">[(</span><span style="color:#204a87;font-weight:bold">column</span><span style="color:#a40000">\</span><span style="color:#000">_name</span><span style="color:#000;font-weight:bold">)]</span>
    <span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">ON</span> <span style="color:#204a87;font-weight:bold">DELETE</span> <span style="color:#204a87;font-weight:bold">CASCADE</span> <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">RESTRICT</span> <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">SET</span> <span style="color:#204a87;font-weight:bold">NULL</span> <span style="color:#000;font-weight:bold">]</span>
    <span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">ON</span> <span style="color:#204a87;font-weight:bold">UPDATE</span> <span style="color:#204a87;font-weight:bold">CASCADE</span> <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">RESTRICT</span> <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">SET</span> <span style="color:#204a87;font-weight:bold">NULL</span> <span style="color:#000;font-weight:bold">]</span> <span style="color:#a40000">}</span>
</code></pre></div><ul>
<li>元组级约束（表约束）</li>
</ul>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-SQL" data-lang="SQL"><span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">CONSTRAINT</span> <span style="color:#204a87;font-weight:bold">constraint</span><span style="color:#a40000">\</span><span style="color:#000">_name</span> <span style="color:#000;font-weight:bold">]</span>
<span style="color:#a40000">{</span> <span style="color:#204a87;font-weight:bold">UNIQUE</span> <span style="color:#000;font-weight:bold">(</span> <span style="color:#000">colname</span> <span style="color:#a40000">{</span> <span style="color:#000;font-weight:bold">,</span> <span style="color:#000">colname</span> <span style="color:#000;font-weight:bold">...</span> <span style="color:#a40000">}</span> <span style="color:#000;font-weight:bold">)</span>
<span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">PRIMARY</span> <span style="color:#204a87;font-weight:bold">KEY</span> <span style="color:#000;font-weight:bold">(</span> <span style="color:#000">colname</span> <span style="color:#a40000">{</span> <span style="color:#000;font-weight:bold">,</span> <span style="color:#000">colname</span> <span style="color:#000;font-weight:bold">...</span> <span style="color:#a40000">}</span> <span style="color:#000;font-weight:bold">)</span>
<span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">CHECK</span> <span style="color:#000;font-weight:bold">(</span> <span style="color:#204a87;font-weight:bold">search</span><span style="color:#a40000">\</span><span style="color:#000">_condition</span> <span style="color:#000;font-weight:bold">)</span>
<span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">FOREIGN</span> <span style="color:#204a87;font-weight:bold">KEY</span> <span style="color:#000;font-weight:bold">(</span> <span style="color:#000">colname</span> <span style="color:#a40000">{</span> <span style="color:#000;font-weight:bold">,</span> <span style="color:#000">colname</span> <span style="color:#000;font-weight:bold">...</span> <span style="color:#a40000">}</span> <span style="color:#000;font-weight:bold">)</span>
  <span style="color:#204a87;font-weight:bold">REFERENCES</span> <span style="color:#204a87;font-weight:bold">table</span><span style="color:#a40000">\</span><span style="color:#000">_name</span> <span style="color:#000;font-weight:bold">[</span> <span style="color:#000;font-weight:bold">(</span> <span style="color:#000">colname</span> <span style="color:#a40000">{</span> <span style="color:#000;font-weight:bold">,</span><span style="color:#000">colname</span><span style="color:#000;font-weight:bold">...</span> <span style="color:#a40000">}</span> <span style="color:#000;font-weight:bold">)</span> <span style="color:#000;font-weight:bold">]</span>
<span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">ON</span> <span style="color:#204a87;font-weight:bold">DELETE</span> <span style="color:#204a87;font-weight:bold">CASCADE</span> <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">RESTRICT</span> <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">SET</span> <span style="color:#204a87;font-weight:bold">NULL</span> <span style="color:#000;font-weight:bold">]</span>
<span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">ON</span> <span style="color:#204a87;font-weight:bold">UPDATE</span> <span style="color:#204a87;font-weight:bold">CASCADE</span> <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">RESTRICT</span> <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">SET</span> <span style="color:#204a87;font-weight:bold">NULL</span> <span style="color:#000;font-weight:bold">]</span> <span style="color:#a40000">}</span>
</code></pre></div><ul>
<li>全局约束（assertion）</li>
</ul>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-SQL" data-lang="SQL"><span style="color:#204a87;font-weight:bold">CREATE</span> <span style="color:#204a87;font-weight:bold">ASSERTION</span>  <span style="color:#ce5c00;font-weight:bold">&lt;</span><span style="color:#000">name</span><span style="color:#ce5c00;font-weight:bold">&gt;</span>  <span style="color:#204a87;font-weight:bold">CHECK</span><span style="color:#000;font-weight:bold">(</span> <span style="color:#ce5c00;font-weight:bold">&lt;</span><span style="color:#000">condition</span><span style="color:#ce5c00;font-weight:bold">&gt;</span> <span style="color:#000;font-weight:bold">)</span>
<span style="color:#204a87;font-weight:bold">DROP</span>   <span style="color:#204a87;font-weight:bold">ASSERTION</span>  <span style="color:#ce5c00;font-weight:bold">&lt;</span><span style="color:#204a87;font-weight:bold">assertion</span><span style="color:#ce5c00;font-weight:bold">-</span><span style="color:#000">name</span><span style="color:#ce5c00;font-weight:bold">-</span><span style="color:#000">list</span><span style="color:#ce5c00;font-weight:bold">&gt;</span>
</code></pre></div><ul>
<li>触发器
<ul>
<li>触发事件（自定义）</li>
<li>结果事件（自定义）</li>
<li>触发过程</li>
</ul>
</li>
</ul>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-SQL" data-lang="SQL"><span style="color:#204a87;font-weight:bold">CREATE</span> <span style="color:#204a87;font-weight:bold">TRIGGER</span> <span style="color:#204a87;font-weight:bold">trigger</span><span style="color:#a40000">\</span><span style="color:#000">_name</span> <span style="color:#a40000">{</span> <span style="color:#204a87;font-weight:bold">BEFORE</span> <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">AFTER</span> <span style="color:#a40000">}</span>
    <span style="color:#a40000">{</span> <span style="color:#204a87;font-weight:bold">INSERT</span> <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">DELETE</span> <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">UPDATE</span> <span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">OF</span> <span style="color:#000">colname</span> <span style="color:#a40000">{</span><span style="color:#000;font-weight:bold">,</span> <span style="color:#000">colname</span> <span style="color:#000;font-weight:bold">...</span> <span style="color:#a40000">}</span><span style="color:#000;font-weight:bold">]</span><span style="color:#a40000">}</span> <span style="color:#204a87;font-weight:bold">ON</span> <span style="color:#204a87;font-weight:bold">table</span><span style="color:#a40000">\</span><span style="color:#000">_name</span> 
    <span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">REFERENCING</span> <span style="color:#a40000">{</span>
        <span style="color:#204a87;font-weight:bold">OLD</span> <span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">ROW</span> <span style="color:#000;font-weight:bold">]</span> <span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">AS</span> <span style="color:#000;font-weight:bold">]</span> <span style="color:#204a87;font-weight:bold">old</span><span style="color:#a40000">\</span><span style="color:#000">_row</span><span style="color:#a40000">\</span><span style="color:#000">_corr</span><span style="color:#a40000">\</span><span style="color:#000">_name</span>
      <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">NEW</span> <span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">ROW</span> <span style="color:#000;font-weight:bold">]</span> <span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">AS</span> <span style="color:#000;font-weight:bold">]</span> <span style="color:#204a87;font-weight:bold">new</span><span style="color:#a40000">\</span><span style="color:#000">_row</span><span style="color:#a40000">\</span><span style="color:#000">_corr</span><span style="color:#a40000">\</span><span style="color:#000">_name</span>
      <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">OLD</span> <span style="color:#204a87;font-weight:bold">TABLE</span> <span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">AS</span> <span style="color:#000;font-weight:bold">]</span> <span style="color:#204a87;font-weight:bold">old</span><span style="color:#a40000">\</span><span style="color:#000">_table</span><span style="color:#a40000">\</span><span style="color:#000">_corr</span><span style="color:#a40000">\</span><span style="color:#000">_name</span>
      <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">NEW</span> <span style="color:#204a87;font-weight:bold">TABLE</span> <span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">AS</span> <span style="color:#000;font-weight:bold">]</span> <span style="color:#204a87;font-weight:bold">new</span><span style="color:#a40000">\</span><span style="color:#000">_table</span><span style="color:#a40000">\</span><span style="color:#000">_corr</span><span style="color:#a40000">\</span><span style="color:#000">_name</span>
      <span style="color:#a40000">}</span> <span style="color:#000;font-weight:bold">]</span>
    
    <span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">FOR</span> <span style="color:#204a87;font-weight:bold">EACH</span> <span style="color:#204a87;font-weight:bold">ROW</span> <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">FOR</span> <span style="color:#204a87;font-weight:bold">EACH</span> <span style="color:#204a87;font-weight:bold">STATEMENT</span> <span style="color:#000;font-weight:bold">]</span>
    <span style="color:#000;font-weight:bold">[</span> <span style="color:#204a87;font-weight:bold">WHEN</span> <span style="color:#000;font-weight:bold">(</span> <span style="color:#204a87;font-weight:bold">search</span><span style="color:#a40000">\</span><span style="color:#000">_condition</span> <span style="color:#000;font-weight:bold">)</span> <span style="color:#000;font-weight:bold">]</span>
    <span style="color:#a40000">{</span> <span style="color:#204a87;font-weight:bold">statement</span> <span style="color:#ce5c00;font-weight:bold">|</span> <span style="color:#204a87;font-weight:bold">BEGIN</span> <span style="color:#204a87;font-weight:bold">ATOMIC</span> <span style="color:#204a87;font-weight:bold">statement</span><span style="color:#000;font-weight:bold">;</span> <span style="color:#a40000">{</span> <span style="color:#204a87;font-weight:bold">statement</span><span style="color:#000;font-weight:bold">;</span> <span style="color:#000;font-weight:bold">...</span> <span style="color:#a40000">}</span> <span style="color:#204a87;font-weight:bold">END</span> <span style="color:#a40000">}</span>

<span style="color:#204a87;font-weight:bold">DROP</span> <span style="color:#204a87;font-weight:bold">TRIGGER</span> <span style="color:#204a87;font-weight:bold">trigger</span><span style="color:#a40000">\</span><span style="color:#000">_name</span>
</code></pre></div>
						</div>
					</main>
					<div class="d-none d-lg-block col-lg-3 bd-toc d-print-none">
						<div class="btn-group-vertical w-100 my-3">
    
    <a class="btn btn-outline-secondary text-dark w-100 p-2" href="https://list.html" target="_blank">
        <i class="iconfont icon-LC_icon_list_line"></i><br />待更新列表
    </a>
    

    
    <a class="btn btn-outline-secondary text-dark w-100 p-2" href="mailto:littlegreedy@qq.com"
        target="_blank">
        <i class="iconfont icon-discussion"></i><br />纠错与咨询
    </a>
    
    
    
    
        <a class="btn btn-outline-secondary text-dark w-100 p-2" href="#" onclick="window.print()">
            <i class="iconfont icon-dayin"></i><br />打印本页
        </a>
    
    
</div>
						<h4 class="card-title pb-0">目录</h4>
						<nav id="TableOfContents">
  <ul>
    <li><a href="#安全性保护-security">安全性保护 (security)</a></li>
    <li><a href="#完整性保护-integrity">完整性保护 (integrity)</a></li>
  </ul>
</nav>
						
						
						<div id="disqus_thread"></div>
							<script>
							

							

							(function() { 
							var d = document, s = d.createElement('script');
							s.src = "https://"+"your site name on disqus"+".disqus.com/embed.js";
							s.setAttribute('data-timestamp', +new Date());
							(d.head || d.body).appendChild(s);
							})();
							</script>
							<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>                  
					  	</div>
						
					</div>
				</div>
			</div>
		</div>
	</div>

	<script
    src="https://code.jquery.com/jquery-3.4.1.min.js"
    integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
    crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script><script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>

<script type="text/javascript" src="https://fziks.gitee.io/custom.min.d3e1b7647f32dbe7e0140398739a26dad3f3470fc1eebe0741ef33668f1b7bd0b2917dc6efb9f0d9f1092b91dca502cab1b883863f02530133a8a8ef609926af.js" integrity="sha512-0&#43;G3ZH8y2&#43;fgFAOYc5om2tPzRw/B7r4HQe8zZo8be9CykX3G77nw2fEJK5HcpQLKsbiDhj8CUwEzqKjvYJkmrw=="></script>
<script type="text/javascript">

document.addEventListener("DOMContentLoaded", function () {
    renderMathInElement(
        document.body, {
            delimiters: [
                {
                    left: "$$",
                    right: "$$",
                    display: true
                },
                {
                    left: "\\[",
                    right: "\\]",
                    display: true
                },
                {
                    left: "$",
                    right: "$",
                    display: false
                },
                {
                    left: "\\(",
                    right: "\\)",
                    display: false
                }
            ],
            strict: false
        }
    );
});


$(document).on('click', 'a[href^="#"]', function (event) {
    event.preventDefault();

    $('html, body').animate({
        scrollTop: $($.attr(this, 'href')).offset().top
    }, 500);
});
</script>




</body>

</html>